<?php

namespace Home\Controller;
use Think\Controller;

//微信配置地址
class ParcelController extends  BaseController {
    
    /**
     * 前台控制器初始化 
     */
     function _initialize(){
       parent::_initialize();
    }
    
    public function index(){
         $parcelModel = D('WxParcel');
      
         $parcelList = $parcelModel->where('isactive = 1')->order('createtime DESC')->select(); 
         if($parcelList != ""){
          foreach ($parcelList as $key => $value) {
               $map['parcelid'] = $value['parcelid'];
                $value['goods'] = array();
               $list = D('wx_parcellist')->alias('a')->where($map)->field('a.goodsid , b.goods_name')->join('left join ki_goods b on a.goodsid=b.goods_id')->group('goodsid')->select();

               foreach ($list as $k => $v) {
                 $where['goodsid'] = $v['goodsid'];
                 $where['parcelid'] = $map['parcelid'];
                 $goodslist = D('wx_parcellist')->field('pb_id,money')->where($where)->select();
                 foreach ($goodslist as $k2 => $v2) {
                        $where2['pb_id']= $v2['pb_id'];
                        $parcelbaselist = D('wx_parcelbase')->where($where2)->field('parcelname')->find();
                        $a = $parcelbaselist['parcelname'].'AU$'.$v2['money'];
                        $v['goods_name'] = $v['goods_name'].','.$a;
           

                 }
                  $value['goods'][] = $v['goods_name'];
              
                
               }
               $parcelList[$key] = $value;
            }
            $this->assign('pagetitle','包邮价');
            $this->assign('list',$parcelList);
            $this->display();
         }
        }

    }
?>